import java.io.*;
import java.net.Socket;

public class test {
    public static void main(String[] args) {
        try (
                // 连接到服务器 (IP + 端口)
                Socket socket = new Socket("127.0.0.1", 8888);
                // 输出流：发送数据
                PrintWriter out = new PrintWriter(
                        new OutputStreamWriter(socket.getOutputStream(), "UTF-8"),
                        true
                );
                // 输入流：接收服务器回信
                BufferedReader in = new BufferedReader(
                        new InputStreamReader(socket.getInputStream(), "UTF-8")
                )
        ) {
            // 发送字符串
            out.println("Hello, Server! 我是客户端 😎");

            // 发送数字（字符串形式，服务端会再 parseInt）
            out.println("12345");

            // 等待服务器回复
            String response = in.readLine();
            System.out.println("服务器回复：" + response);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
